#ifdef ONLINE_JUDGE
    #include<stdio.h>
    #include<stdlib.h>
    #define INPUT stdin
    int main(){
#else
    #include"header.h"
    #define INPUT fptIn
    int acm_00488() {
        printf("--ACM 488 begin here--\n");
        FILE *fptIn = fopen("Resource/acm_00488.txt", "r");
        if(fptIn == NULL)
        {
            printf("File load failed\n");
            system("pause");
            exit(1);
        }
#endif

    int runTimes = 0, ampl = 0, freq = 0 ;
    int i, j;
    fscanf(INPUT ," %d",&runTimes);
    while(runTimes > 0 ){// A term of data
        fscanf(INPUT ," %d %d",&ampl,&freq);
        for( ; freq > 0 ; freq = freq - 1 ){// Frequency
            for( i = 1 ; i <= ampl ; i = i + 1 ){// Upper and mid Part
                for(j = 0 ; j < i ; j = j + 1){//Single line
                    printf("%d",i);
                }
                printf("\n");
            }
            for( i = (ampl-1) ; i > 0 ; i = i - 1 ){// Lower Part
                for(j = 0 ; j < i ; j = j + 1){//Single line
                    printf("%d",i);
                }
                printf("\n");
            }//End lower part
            if( (runTimes > 1) || (freq > 1) )
                printf("\n");
        }//End a frequency
        runTimes = runTimes - 1;
    }//End a term data
    #ifndef ONLINE_JUDGE
        printf("--ACM 488 end here--\n");
        fclose(INPUT);
    #endif
    return 0;
}
